//
// main.cpp for plazza in /home/peelou/SVN/pizzaillo
// 
// Made by gery baudry
// Login   <baudry_g@epitech.net>
// 
// Started on  Mon Apr 15 20:30:10 2013 gery baudry
// Last update Wed Apr 17 13:39:17 2013 florian dewulf
//

#include	<iostream>

void		main_loop(char **av)
{
  Lexer		lex(av[1], av[2], av[3]);
  Accueil	acc;
  Thread	th;
  string	str = "";

  while (1) {
    bool	indice = false;

    acc = acc.readCmd();
    for (list<CuisineLink>::iterator it = acc.getLink().begin() ; it != acc.getLink().end() ; ++it)
      {
	if (it->getState() == false)
	  it = acc.getLink().erase(it);
	else {
	  while (it->getReady() == "");
	  if (it->getReady() == "ok")
	    {
	      it->setCmd(
	      it->sendCmd();
	    }
	}
      }
  }
}

int		main(int ac, char **av)
{
  if (ac == 4 && Lexer::checkAv(av[1], av[2], av[3]))
    {
      try
	{
	  main_loop(av);
	}
      catch (const Exception &e)
	{
	  std::cerr << "Error : " << e.what() << std::endl;
	  return (-1);
	}
    }
  else {
    std::cout<<"[USAGE] ./plazza [multiplicateur] [nonbre Cuistot] [temps milisec]"<<std::endl;
    return (0);
  }
}
